#include "ThreadPool.hpp"
#include "Log.hpp"
#include "Task.hpp"
#include <iostream>
#include <memory>
#include <ctime>

int main()
{
    srand(time(nullptr) ^ getpid());
    EnableScreen(); // 开启日志
    unique_ptr<ThreadPool<Task>> tp = make_unique<ThreadPool<Task>>(5);//c++14  Task!
    tp->InitThreadPool();
    tp->Start();

    int tasknum = 10;
    while(tasknum)
    {
        int a = rand() % 10 + 1;
        usleep(1000);
        int b = rand() % 20 + 1;  
        Task t(a, b);
        LOG(INFO, "main thread push task: %s", t.DTostring().c_str());
        tp->Enqueue(t);
        sleep(1);
        tasknum--;
    }

    tp->Stop();
    tp->Wait();

    //EnableFile();
    // EnableScreen();

    // LOG(DEBUG, "hello %d %s %f", 10, "world", 7.11);
    // LOG(INFO, "hello yss");

    return 0;
}